package org.karelun.whiteboard.gef.ui.actions;

import java.util.Collection;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.edit.command.PasteFromClipboardCommand;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionFactory;

public class PasteAction extends SelectionAction{

	public PasteAction(IEditorPart editor) {
		super(editor);
		setId(ActionFactory.PASTE.getId());
	}

	@Override
	protected Command createCommand() {
		Collection<Object> collection = getSelectedEditPartModels();
		if(collection.size()==1){
			return PasteFromClipboardCommand.create(getEditingDomain(), collection.iterator().next(), null);
		}
		return UnexecutableCommand.INSTANCE;
	}
}
